Skip to content

feat(ICRC-Ledger): DEFI-1687: implement ICRC-107 fee collector#8217

Open
maciejdfinity wants to merge 129 commits intomasterfrom
maciej-ledger-feecol
Open

feat(ICRC-Ledger): DEFI-1687: implement ICRC-107 fee collector#8217
maciejdfinity wants to merge 129 commits intomasterfrom
maciej-ledger-feecol

Conversation

@maciejdfinity
Copy link
Copy Markdown
Contributor

@maciejdfinity maciejdfinity commented Jan 5, 2026

With this change the ICRC ledger now implements the ICRC-107 fee collector standard as described in https://github.com/dfinity/ICRC/blob/main/ICRCs/ICRC-107/ICRC-107.md. The legacy fee collector is no longer supported by the ledger. This results in the following notable changes:

  • If a fee collector is present, approval fees are also collected.
  • If an existing ledger has a legacy fee collector configured, the legacy fee collector will be converted to the ICRC-107 fee collector during the upgrade to this or later version.

The fee collector can be configured using the existing fee_collector_account init argument and change_fee_collector upgrade argument.

Since the ICRC-107 fee collector change is not backwards compatible, the ledger upgraded to this version cannot be downgraded to an earlier version.

@maciejdfinity maciejdfinity changed the title add set fee collector arg and error feat(ICRC-Ledger): DEFI-1687: implement ICRC-107 fee collector Jan 5, 2026
@github-actions github-actions Bot added the feat label Jan 5, 2026
Base automatically changed from maciej-schema-feecol to master January 7, 2026 14:03
Copy link
Copy Markdown
Contributor

@mbjorkqvist mbjorkqvist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @maciejdfinity! I have a few comments and questions, but overall this looks very good!

Comment thread MODULE.bazel
"ck_btc_ledger": "ic-icrc1-ledger.wasm.gz",
"ck_btc_ledger_v1": "ic-icrc1-ledger.wasm.gz",
"ck_btc_ledger_v3": "ic-icrc1-ledger.wasm.gz",
"ck_btc_ledger_v5": "ic-icrc1-ledger.wasm.gz",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to rename this to something more descriptive, and/or perhaps add a comment somewhere (I think comments don't work in mainnet-canister-revisions.json, but here would be ok?)? Especially since the v5 doesn't correspond to the LEDGER_VERSION, so it can be confusing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Maybe we could change it to correspond to the ledger versions, i.e.:
v1 -> no_mem_mgr
v3 -> v1
v5 -> v3
WDYT?

Comment on lines +30 to +33
"ck_btc_ledger_v5": {
"rev": "512cf412f33d430b79f42330518166d14fc6884e",
"sha256": "901bc548f901145bd15a1156487eed703705794ad6a23787eaa04b1c7bbdcf48"
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This points to ledger-suite-icrc-2025-04-14. Is there a particular reason for this specific version, or could we use ledger-suite-icrc-2025-10-27, which is the minimum version we point to from the currently most recent version ledger-suite-icrc-2026-02-02?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason, I just used the same version as current mainnet ledger :) Changed!

Comment thread rs/ledger_suite/icrc1/index-ng/tests/tests.rs Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to move all the fee collector-related tests to a separate file? rs/ledger_suite/icrc1/index-ng/tests/tests.rs is already over 2000 lines.

Also, would it make sense to add tests for the following (unless they already exist and I missed them):

  • Trying to set the fee collector account to the minting account, the anonymous account, and an invalid account (e.g., an account with an invalid principal). For the init, upgrade, and endpoint fee collector setting paths. IIUC, there's a check for the minting account in the init and upgrade paths, but not for the endpoint?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I did not check for minting or anonymous account in the endpoint and init/upgrade did not check for the anonymous account. I added test_fee_collector_107_minting_account and test_fee_collector_107_anonymous which cover the 6 cases: (minter, anonymous)x(endpoint, init, upgrade).
As for the invalid Account - since this is a candid endpoint, I don't think we have to check that - we always receive a valid Account, invalid Accounts should be rejected by cdk?

I also moved the index tests to a separate file.

Comment on lines +152 to +164
// Downgrade to mainnet is currently not possible. The rest of the test can
// be uncommented again, once the PR that introduced this line is on mainnet.

// // Downgrade the ledger to the mainnet version that does not support ICRC-106
// env.upgrade_canister(canister_id, mainnet_ledger_wasm, encoded_empty_upgrade_args)
// .expect("should successfully downgrade ledger canister");
// assert_index_not_set(&env, canister_id, false);

// // Upgrade to a ledger version that supports ICRC-106, but do not set the index principal
// let encoded_empty_upgrade_args = Encode!(&encode_empty_upgrade_args()).unwrap();
// env.upgrade_canister(canister_id, ledger_wasm, encoded_empty_upgrade_args)
// .expect("should successfully upgrade ledger canister");
// assert_index_not_set(&env, canister_id, true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it help to have a ticket in the ICRC-107 epic to remember to uncomment this, and the other snippet in rs/ledger_suite/icrc1/tests/upgrade_downgrade.rs, once this has been released and deployed to mainnet? Or will the tests fail anyway once that happens, and uncommenting cannot be forgotten?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be forgotten, I created https://dfinity.atlassian.net/browse/DEFI-2657

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants